import tkinter
from interface.widget import PagePort, scale_factor
from interface.pages.login import LoginPage
from interface.pages.multi_send_file import MultiSendFilePage
import ctypes


class Application:
    def __init__(self):
        try:  # Windows
            ctypes.windll.shcore.SetProcessDpiAwareness(1)
        except AttributeError:  # Linux
            pass
        except OSError:  # Happens on some old computer.
            pass

        self.page_port = None
        self.tk = tkinter.Tk()
        self.tk.geometry('{}x{}'.format(int(800 * scale_factor), int(600 * scale_factor)))
        self.tk.title('数据传输程序')

    def content(self, master):
        page_port = PagePort(master)
        page_port.relwidth = 1
        page_port.relheight = 1
        page_port.display()
        page_port.open_page(LoginPage(page_port))
        self.page_port = page_port

    def mainloop(self):
        self.content(self.tk)
        self.tk.mainloop()
